package com.example.demo.Config.FileConfig;

import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
@Slf4j
public class WebMvcConfig implements WebMvcConfigurer {

    public static final String LocalPath="/Users/wujunhao/desktop/docker-image/wzq/";
    public static final String WebMvcPath="http://localhost:8080/img/";
    //静态资源映射
    @Override
    public void addResourceHandlers(@NotNull ResourceHandlerRegistry registry) {
        try {
            registry.addResourceHandler("/img/**").addResourceLocations("file:"+LocalPath);
        } catch (Exception e) {
            log.error("错误{}", e.getMessage());
        }
    }
}
